<?php


namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Controller;
use App\Models\Setting;
use App\Models\SettingJs;
use App\Utils\MyLog;
use App\Utils\ResponseUtil;

// 官网首页设置管理控制器
class WebManageController extends Controller
{
    // get
    public function settings()
    {
        $settings = Setting::query()->select(['name','val'])->get();
        return ResponseUtil::success($settings);
    }

    //put
    public function setting(){
        $name = request()->post('name');
        $val = request()->post('val');
        Setting::query()->where('name',$name)->update(['val'=>$val]);
        return ResponseUtil::success();
    }


    // get
    public function settingsJs()
    {
        $settings = SettingJs::query()->select(['name','val'])->get();
        return ResponseUtil::success($settings);
    }

    //put
    public function settingJs(){
        $name = request()->post('name');
        $val = request()->post('val');
        MyLog::info('提交保存的信息'.json_encode( request()->all()));
        SettingJs::query()->where('name',$name)->update(['val'=>$val]);
        return ResponseUtil::success();
    }


}
